/*****************************************************************************
* | File        :   sysfs_gpio.h
* | Author      :   Luckfox team
* | Function    :   Drive SC16IS752 GPIO
* | Info        :   Read and write /sys/class/gpio
*----------------
* |	This version:   V2.0
* | Date        :   2023-06-26
* | Info        :   Basic version
*
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to  whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#ifndef __SYSFS_GPIO_DEBIAN_
#define __SYSFS_GPIO_DEBIAN_

#include <stdio.h>

#define IN 0
#define OUT 1

#define LOW 0
#define HIGH 1

#define NUM_MAXBUF 4
#define DIR_MAXSIZ 60

#define SYSFS_GPIO_DEBUG 1
#if SYSFS_GPIO_DEBUG
#define SYSFS_GPIO_Debug(__info, ...) printf("Debug: " __info, ##__VA_ARGS__)
#else
#define SYSFS_GPIO_Debug(__info, ...)
#endif

// 22PIN + 2PIN UART0 + 2PIN I2C0 + 2PIN I2C
// + 2PIN 3V3 + 2PIN 5V + 8PIN GND  = 40PIN
/*******************/

#define I2C0_SDA  18  // 3,18
#define I2C0_SCL  17  // 5,17
#define UART8_TX  70  // 7,70
#define GPIO17    98  //11,98
#define GPIO27    99  //13,99
#define GPIO22    13  //15.13
#define SPI0_MOSI 24  //19,24 
#define SPI0_MISO 25  //21,25
#define SPI0_CLK  23  //23,23
#define I2C8_SDA  79  //27,79
#define UART8_RX  71  //29,71
#define GPIO6    151  //31,151
#define GPIO13    97  //33,97
#define SPI4_MISO 138 //35,138 
#define GPIO26    72  //37,72
#define UART2_TX  141 //8,141
#define UART2_RX  140 //10,140 
#define PWM2      27  //12,27
#define GPIO23    12  //16,12
#define GPIO24    21  //18,21
#define GPIO25    77  //22,77
#define SPI0_CS0  22  //24,22
#define SPI0_CS1  19  //26,19
#define I2C8_SCL  78  //28,78
#define GPIO12    96  //32,96
#define GPIO16    95  //36,95
#define SPI4_MOSI 137 //38,137
#define SPI4_CLK  136 //40,136



int SYSFS_GPIO_Export(int Pin);
int SYSFS_GPIO_Unexport(int Pin);
int SYSFS_GPIO_Direction(int Pin, int Dir);
int SYSFS_GPIO_Read(int Pin);
int SYSFS_GPIO_Write(int Pin, int value);

#endif
